package com.example.md.mddemo.common;

import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.chrono.ChronoZonedDateTime;
import java.util.Date;

/**
 * Copyright © 2018年 ziniuxiaozhu. All rights reserved.
 *
 * @Author 临江仙 hzqiuxm@163.com
 * TODO:亲爱的临江仙，请写点注释吧...........
 * @Date 2018/9/19 14:36
 */
public class MyDateUtils {

    public static LocalDate DateToLocaleDate(Date date) {

        Instant instant = date.toInstant();
        ZoneId zoneId  = ZoneId.systemDefault();

        return instant.atZone(zoneId).toLocalDate();

    }

    public static Date LocalDateToDate(LocalDate localDate) {

        ZoneId zoneId = ZoneId.systemDefault();
        ChronoZonedDateTime<LocalDate> zonedDateTime = localDate.atStartOfDay(zoneId);

        return Date.from(zonedDateTime.toInstant());

    }
}
